package org.wu.framework.core.io;

import org.wu.framework.core.io.ScriptResource;
import org.wu.framework.core.utils.HttpFileUtil;

import java.io.IOException;
import java.io.InputStream;

public class UrlScriptResource implements ScriptResource {

    private final String path;

    public UrlScriptResource(String path) {
        this.path = path;
    }

    /**
     * 脚本名称
     *
     * @return 脚本名称
     */
    @Override
    public String getPath() {
        return path;
    }

    /**
     * 获取 文件流文件
     *
     * @return 文件流文件
     * @throws IOException
     */
    @Override
    public InputStream getInputStream() throws IOException {
        return HttpFileUtil.readInputStream(path);
    }
}
